package com.example.stringbufferlogger.controller;

import com.example.stringbufferlogger.entity.LogRecord;
import com.example.stringbufferlogger.service.LogRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logRecords")
public class LogRecordController {

    @Autowired
    private LogRecordService logRecordService;

    /**
     * 根据请求 ID 查询日志记录
     * @param requestId 请求 ID
     * @return 日志记录对象
     */
    @GetMapping("/{requestId}")
    public LogRecord getLogRecordByRequestId(@PathVariable String requestId) {
        return logRecordService.getLogRecordByRequestId(requestId);
    }

    /**
     * 查询所有日志记录
     * @return 日志记录列表
     */
    @GetMapping
    public List<LogRecord> getAllLogRecords() {
        return logRecordService.getAllLogRecords();
    }

}
